package com.gitee.ywj1352.listener;

import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.kafka.support.Acknowledgment;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author wenjie.yang on 2019/6/21.
 */
@Component
public class KafkaConsumerListener {

    //@KafkaListener(topics = "annotated1",containerFactory = "getKafkaListenerContainerFactory")
    public void listen1(List<ConsumerRecord<?, ?>> records, Acknowledgment ack) {
        records.forEach(consumerRecord -> {
            System.out.println(consumerRecord.value());
            ack.acknowledge();//手动提交偏移量
        });
    }

}
